home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BKISSSRC.ZIP / SINUS / BITMAP.INC next >
Encoding:
Text File  |  1994-02-11  |  5.7 KB  |  128 lines

  1. ;----------------------------------------------------------------------
  2. ;
  3. ; void add_bitmap(X, Y, ScrnOffs, Width, Height, char far *Bitmap)
  4. ;
  5. ;----------------------------------------------------------------------
  6. proc        add_bitmap
  7. arg         X:word,Y:word,ScrnOffs:word,Width:word,Height:word,Bitmap:dword
  8.             push bp                         ;\ initialize our stack frame
  9.             mov bp,sp                       ;/
  10.             push ds si
  11.             cld                             ;clear the direction flag
  12.             mov es,[VGASeg]                 ;\
  13.             mov ax,[Y]                      ; \
  14.             mul [ModeXLogWidth]             ;  \
  15.             mov di,[ScrnOffs]               ;   \ ES:DI ==> video segment position
  16.             add di,ax                       ;   /
  17.             mov cx,[X]                      ;  /
  18.             shr cx,2                        ; /
  19.             add di,cx                       ;/
  20.             lds si,[Bitmap]                 ;DS:SI ==> Bitmap data
  21.             mov [@@Plane],0                 ;Set plane counter to 0
  22.             mov [@@Source],si               ;\ save our pointers
  23.             mov [@@Target],di               ;/
  24. @@PlaneLoop:mov cl,[@@Plane]                ;\
  25.             mov ah,1                        ; \ send out plane to write to
  26.             shl ah,cl                       ; /
  27.             @Set_Write_Plane                ;/
  28.             mov ah,[@@Plane]                ;\ send out the plane to read from
  29.             @Set_Read_Plane                 ;/
  30.             
  31.             mov si,[@@Source]
  32.             mov di,[@@Target]
  33.  
  34.             mov dx,[Height]                 ;DX = number of rows in image
  35. @@RowLoop:  mov cx,[Width]                  ;CX = number of columns in image
  36.             dec cx                          ;     minus one
  37.             mov [@@TempRow],di
  38. @@ColLoop:  mov al,[byte ds:si]             ;\
  39.             add si,4                        ; \
  40.             add [byte es:di],al             ;  \ write the pixel
  41.             jnc @@NoCarry                   ;  /
  42.             mov [byte es:di],0FFh           ; /
  43. @@NoCarry:  inc di                          ;/
  44.             sub cx,4                        ;\ do the next column
  45.             jnc @@ColLoop                   ;/
  46.             mov di,[@@TempRow]
  47.             add di,[ModeXLogWidth]
  48.             dec dx                          ;\ do the next row
  49.             jnz @@RowLoop                   ;/
  50.             inc [@@Source]                  ;\
  51.             inc [@@Plane]                   ; \ do the next plane
  52.             cmp [@@Plane],4                 ; /
  53.             jnz @@PlaneLoop                 ;/
  54.  
  55.             pop si ds
  56.             pop bp                          ;deinitialize the stack frame
  57.             ret                             ;return
  58. @@Plane     db ?
  59. @@Source    dw ?
  60. @@Target    dw ?
  61. @@TempRow   dw ?
  62. endp        add_bitmap
  63.  
  64.  
  65. ;----------------------------------------------------------------------
  66. ;
  67. ; void sub_bitmap(X, Y, ScrnOffs, Width, Height, char far *Bitmap)
  68. ;
  69. ;----------------------------------------------------------------------
  70. proc        sub_bitmap
  71. arg         X:word,Y:word,ScrnOffs:word,Width:word,Height:word,Bitmap:dword
  72.             push bp                         ;\ initialize our stack frame
  73.             mov bp,sp                       ;/
  74.             push ds si
  75.             cld                             ;clear the direction flag
  76.             mov es,[VGASeg]                 ;\
  77.             mov ax,[Y]                      ; \
  78.             mul [ModeXLogWidth]             ;  \
  79.             mov di,[ScrnOffs]               ;   \ ES:DI ==> video segment position
  80.             add di,ax                       ;   /
  81.             mov cx,[X]                      ;  /
  82.             shr cx,2                        ; /
  83.             add di,cx                       ;/
  84.             lds si,[Bitmap]                 ;DS:SI ==> Bitmap data
  85.             mov [@@Plane],0                 ;Set plane counter to 0
  86.             mov [@@Source],si               ;\ save our pointers
  87.             mov [@@Target],di               ;/
  88. @@PlaneLoop:mov cl,[@@Plane]                ;\
  89.             mov ah,1                        ; \ send out plane to write to
  90.             shl ah,cl                       ; /
  91.             @Set_Write_Plane                ;/
  92.             mov ah,[@@Plane]                ;\ send out the plane to read from
  93.             @Set_Read_Plane                 ;/
  94.             
  95.             mov si,[@@Source]
  96.             mov di,[@@Target]
  97.  
  98.             mov dx,[Height]                 ;DX = number of rows in image
  99. @@RowLoop:  mov cx,[Width]                  ;CX = number of columns in image
  100.             dec cx                          ;     minus one
  101.             mov [@@TempRow],di
  102. @@ColLoop:  mov al,[byte ds:si]             ;\
  103.             add si,4                        ; \ write the pixel
  104.             sub [byte es:di],al             ; /
  105.             jnc @@NoCarry
  106.             mov [byte es:di],0
  107. @@NoCarry:  inc di                          ;/
  108.             sub cx,4                        ;\ do the next column
  109.             jnc @@ColLoop                   ;/
  110.             mov di,[@@TempRow]
  111.             add di,[ModeXLogWidth]
  112.             dec dx                          ;\ do the next row
  113.             jnz @@RowLoop                   ;/
  114.             inc [@@Source]                  ;\
  115.             inc [@@Plane]                   ; \ do the next plane
  116.             cmp [@@Plane],4                 ; /
  117.             jnz @@PlaneLoop                 ;/
  118.  
  119.             pop si ds
  120.             pop bp                          ;deinitialize the stack frame
  121.             ret                             ;return
  122. @@Plane     db ?
  123. @@Source    dw ?
  124. @@Target    dw ?
  125. @@TempRow   dw ?
  126. endp        sub_bitmap
  127.  
  128.